#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef struct ti{
	int score;
	int x;
	int y;
	int cuo;
	string ans;
	
}Ti;
int a[1005];
int cuo[105];
Ti t[105];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>t[i].score >>t[i].x>>t[i].y;
		for(int j=1;j<=t[j].y ;j++){
			char ch;
			cin>>ch;
			t[j].ans +=ch;
		}
	}
	int max=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char ch;
			int x;
			string b;
			cin>>ch>>x;
			for(int k=1;k<=x;k++){
				cin>>ch;
				b+=ch;
			}
			cin>>ch;
			if(b==t[j].ans ){
				a[i]+=t[j].score ;
			}else{
				cuo[j]++;
			}
		
			if(max<cuo[j])
			max=cuo[j];
		}
		cout<<a[i]<<endl;		
	}
		if(max==0){
		cout<< "Too simple";
		}else{
			cout<<max;
			for(int i=1;i<=m;i++){
				if(cuo[i]==max){
					cout<<" "<<i;
				}
			} 
		}
		return 0;
}
